package com.hhs.storage.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.hhs.storage.bean.PersonnelFilesType;
import com.hhs.storage.bean.ResponseInfo;
import com.hhs.storage.dao.PersonnelFilesTypeDao;
import com.hhs.storage.service.PersonnelFilesTypeService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hhs.storage.util.SysUtil;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author chx
 * @since 2024-01-27
 */
@Service
public class PersonnelFilesTypeServiceImpl extends ServiceImpl<PersonnelFilesTypeDao, PersonnelFilesType> implements PersonnelFilesTypeService {

    @Resource
    private HttpServletRequest request;

    @Override
    public Map<String, Object> getSelectAll() {
        LambdaQueryWrapper<PersonnelFilesType> lqw = new LambdaQueryWrapper<>();
        lqw.eq(PersonnelFilesType::getUserId,SysUtil.getLoginUserId(request));
        List<PersonnelFilesType> list = this.list(lqw);

        Map<String,Object> map =new HashMap<>();
        map.put("code",1);
        map.put("data",list);

        return map;
    }

    @Override
    public Map<String, Object> addSelectType(PersonnelFilesType personnelFilesType) {

        personnelFilesType.setId(SysUtil.UUID());
        personnelFilesType.setUserId(SysUtil.getLoginUserId(request));
        this.save(personnelFilesType);

        return ResponseInfo.success("添加成功");
    }
}
